
from whiff import resolver
from whiff import whiffenv
from whiff.middleware import misc

import drawSchema

class schemaCallback(misc.utility):
    def __call__(self, env, start_response):
        env = resolver.process_cgi(env, parse_cgi=True)
        dataString = whiffenv.cgiGet(env, "data", "{}")
        dataString = resolver.unquote(dataString)
        #pr "got datastring", dataString
        programMaker = drawSchema.__middleware__(canvasId="testCanvas", clickCallback="canvasClickCallback",
                                                 eventListenerVariable="eventListenerVariable",
                                                 schemaJson=dataString)
        return self.deliver_page(programMaker, env, start_response)

__middleware__ = schemaCallback
